import Page
from Page import Service
from Base.Base import Base
from selenium.webdriver.common.by import By


class ServiceHealthHousekeeperPage(Base):
    """
    健康管家页
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.health_home_btn = (By.XPATH, Service.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.health_back_btn = (By.XPATH, Service.RESOURCE_ID.format('ivBack'))

        # 用油会计标题
        self.health_oil_accounting_btn = (By.XPATH, Service.RESOURCE_ID.format("id_1"))

        # 电池助手标题
        self.health_battery_assistant_btn = (By.XPATH, Service.RESOURCE_ID.format("id_2"))

        # 驾驶地图标题
        self.health_driving_map_btn = (By.XPATH, Service.RESOURCE_ID.format("id_3"))

        # 车辆故障标题
        self.health_vehicle_failure_btn = (By.XPATH, Service.RESOURCE_ID.format("id_4"))

        # 网络不给力文字
        self.health_network_not_good_text = (By.XPATH, Service.RESOURCE_ID.format("tv_tips"))

        # 重新加载按钮
        self.health_reload_btn = (By.XPATH, Service.RESOURCE_ID.format("tv_retry"))

        # 蓄电池电量
        self.health_battery_power_text = (By.XPATH, Service.RESOURCE_ID.format("tv_electricity"))

        # 蓄电池图片
        self.health_battery_power_picture_icon = (By.XPATH, Service.RESOURCE_ID.format("iv_electricity"))

        # 蓄电池健康
        self.health_battery_power_health_text = (By.XPATH, Service.RESOURCE_ID.format("tv_quality"))

        # 蓄电池图片
        self.health_battery_power_health_picture_icon = (By.XPATH, Service.RESOURCE_ID.format("iv_quality"))

        # 危险驾驶地图
        self.health_dangerous_driving_map_btn = (By.XPATH, Service.RESOURCE_ID.format("second_page_title"))

        # 油耗地图
        self.health_fuel_consumption_map_btn = (By.XPATH, Service.RESOURCE_ID.format("second_page_title"))

        # 危险代表驾驶按钮
        self.health_driving_danger_btn = (By.XPATH, Page.TEXT.format("代表危险驾驶"))

        # 近期油耗统计按钮
        self.health_recent_fuel_consumption_statistics_btn = (By.XPATH, Service.RESOURCE_ID.format("tv_danger_events"))

        # 暂无数据文案
        self.health_no_data_text = (By.XPATH, Service.RESOURCE_ID.format("tv_tips"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.health_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.health_back_btn)

    def click_oil_accounting(self):
        """
        点击用油会计标题

        :return:None
        """
        self.click_element(self.health_oil_accounting_btn)

    def get_oil_accounting(self):
        """
        获取用油会计标题

        :return:获取元素
        """
        return self.find_element_o(self.health_oil_accounting_btn)

    def click_battery_assistant(self):
        """
        点击电池助手标题

        :return:None
        """
        self.click_element(self.health_battery_assistant_btn)

    def get_battery_assistant(self):
        """
        获取电池助手标题

        :return:获取元素
        """
        return self.find_element_o(self.health_battery_assistant_btn)

    def click_driving_map(self):
        """
        点击驾驶地图标题

        :return:None
        """
        self.click_element(self.health_driving_map_btn)

    def get_driving_map(self):
        """
        获取驾驶地图标题

        :return:获取元素
        """
        return self.find_element_o(self.health_driving_map_btn)

    def click_vehicle_failure(self):
        """
        点击车辆故障标题

        :return:None
        """
        self.click_element(self.health_vehicle_failure_btn)

    def get_vehicle_failure(self):
        """
        获取车辆故障标题

        :return:获取元素
        """
        return self.find_element_o(self.health_vehicle_failure_btn)

    def get_network_not_good(self):
        """
        获取网络不给力文字

        :return:获取元素
        """
        return self.find_element_o(self.health_network_not_good_text)

    def click_reload(self):
        """
        点击重新加载按钮

        :return:None
        """
        self.click_element(self.health_reload_btn)

    def get_battery_power(self):
        """
        获取蓄电池电量文案

        :return:获取元素
        """
        return self.find_element_o(self.health_battery_power_text)

    def get_battery_power_picture(self):
        """
        获取蓄电池图片

        :return:获取元素
        """
        return self.find_element_o(self.health_battery_power_picture_icon)

    def get_battery_power_health(self):
        """
        获取蓄电池健康

        :return:获取元素
        """
        return self.find_element_o(self.health_battery_power_health_text)

    def get_battery_power_health_picture(self):
        """
        获取蓄电池健康图片

        :return:获取元素
        """
        return self.find_element_o(self.health_battery_power_health_picture_icon)

    def click_dangerous_driving_map(self):
        """
        点击危险驾驶地图按钮

        :return:None
        """
        self.click_element(self.health_dangerous_driving_map_btn)

    def click_fuel_consumption_map(self):
        """
        点击油耗地图按钮

        :return:None
        """
        self.click_element(self.health_fuel_consumption_map_btn)

    def click_driving_danger(self):
        """
        点击危险驾驶按钮

        :return:None
        """
        self.click_element(self.health_driving_danger_btn)

    def click_recent_fuel_consumption_statistics(self):
        """
        点击近期油耗统计按钮

        :return:None
        """
        self.click_element(self.health_recent_fuel_consumption_statistics_btn)

    def get_no_data(self):
        """
        获取暂无数据文案

        :return:获取元素
        """
        return self.find_element_o(self.health_no_data_text)

    def is_display_oil_accounting(self):
        """
        是否进入用油会计界面

        :return: bool
        """
        return self.is_display(self.health_network_not_good_text)

    def is_display_battery_assistant(self):
        """
        是否进入电池助手界面

        :return: bool
        """
        return self.is_display(self.health_battery_power_text)

    def is_display_driving_map(self):
        """
        是否进入驾驶地图界面

        :return: bool
        """
        return self.is_display(self.health_dangerous_driving_map_btn)

    def is_display_vehicle_failure(self):
        """
        是否进入车辆故障界面

        :return: bool
        """
        return self.is_display(self.health_no_data_text)

    def is_display_health(self):
        """
        是否进入健康管家界面

        :return: bool
        """
        return self.is_display(self.health_oil_accounting_btn)
